function deepEqual(obj1, obj2) {
  if (obj1 === null && obj2 === null) return true;
  if (typeof obj1 !== 'object' && typeof obj2 !== 'object') {
    return obj1 === obj2;
  }

  // 检查长度是否相同
  if (Object.keys(obj1).length !== Object.keys(obj2).length) return false;

  for (const key in obj1) {
    // 递归比较
    if (!deepEqual(obj1[key], obj2[key])) {
      return false;
    }
  }
  return true;
}

const obj1 = {
  name: 'John',
  age: 30,
  address: {
  street: '123 Main St',
  city: 'New York'
  }
};

const obj2 = {
  name: 'John',
  age: 30,
  address: {
  street: '123 Main St',
  city: 'New York'
  }
};

console.log(deepEqual(obj1, obj2));

